package com.atguigu.gmall.search.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * {
 *  "id": 1,
 *  "name": "张三"
 *  "address": "贵州"
 *  "age": 18
 * }
 */

//JavaBean  上使用注解声明bean与es数据的映射信息

@Data
@Document(indexName = "gmallperson",
        createIndex = true,
        shards = 3,
        replicas = 2)

@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Person {

    @Id
    private Long id;  //主键字段

    @Field(type = FieldType.Keyword)
    private String name; //TEXT

    @Field(type = FieldType.Text)
    private String address;


    //SpringData: 7.6.2   实际:7.13  FieldType.AUTO不能生效
    @Field(type = FieldType.Integer)   //这是es文档要保存的数据
    private Integer age;
//    @Transient
//    private Integer hello;


}
